import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
// 组件
import '@c/'
import '@/hbui'
// 模块
import Index from '@t/index/a'

import User from '@t/user/' // 用户[注册, 登陆, 忘记密码, 身份认证, 邀请, 安全]
import Look_trade from '@t/look_trade/' // 交易["k线+撮合", 点对点广告, 订单, 资产中心]
import NoticeBox from '@t/noticebox/' // 公告[公告]

import test from '@t/test/a' // just for test

const rt = new Router({
	routes: [
		{
			path: '/index',
			name: 'index',
			component: Index,
			alias: '/',
		},
		{
			path: '/test',
			name: 'test',
			component: test,
		},
		...Look_trade,
		...User,
		...NoticeBox,
	],
	scrollBehavior() {
		return {
			x: 0,
			y: 0,
		}
	},
})

rt.beforeEach((to, from, next) => {
	let box = []
	let [re, re0, re1, re2] = [false, false, false, false]
	// 如果是从[注册页, 忘记密码页]跳到登陆页, 登陆后应该跳到主页
	box = ['signup', 'forgotpwd']
	re0 = box.includes(from.name)
	re1 = to.name === 'signin'
	re = re0 && re1
	Vue.prototype.$mengxin = re ? true : false

	next()
})

export default rt
